package demo;

public class Smart {

    public void control(JD jd) {//控制开关
        System.out.println(jd.getName() + " 当前的状态: "+(jd.isStatus()?"开":"关"));
        System.out.println("按下开关");
        jd.press();//调用接口
        System.out.println(jd.getName() + " 当前的状态: "+(jd.isStatus()?"开":"关"));
    }

    public void print(JD[] jds) {//打印所有开关的状态
        for (int i = 0; i < jds.length; i++) {
            System.out.println((i+1) + jds[i].getName() + " 当前的状态: "+(jds[i].isStatus()?"开":"关"));
        }
            System.out.println("=======================");
    }
}
